﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace HPPClientLibrary.XmlableObject
{
    public class ClientFile:IXmlable
    {
        private File _file;

        public ClientFile(File file)
        {
            _file = file;
        }
        public virtual XDocument ToXml()
        {
            XDocument xdoc = new XDocument();
            xdoc.Declaration = new XDeclaration("1.0", "utf-8", "yes");
            XElement fileNode = new XElement("File");
            if (_file == null)
            {
                xdoc.Add(fileNode);
                return xdoc;
            }
            fileNode.Add(new XElement("FileHash ", new XAttribute("Hash", _file.Hash)), new XElement("HasBlocks ", new XAttribute("Blocks",_file.FileBlocks.GetHexString())));
            xdoc.Add(fileNode);
            return xdoc;
        }

        public File File
        {
            get { return _file; }
            set { _file = value; }
        }
    }
}
